#ifndef LCD_H
#define LCD_H


// forward declarations
class Serial;


/**
 class for maintaining scrolling text on a LCD
*/
class Lcd
{
  public:
    Lcd(Serial *_pSerial, unsigned int _uWidth, unsigned int _uHeight);
    virtual ~Lcd();

    /// sets the backlight brightness (0 - 29)
    void setBacklight(unsigned char _uValue);

    /// update text on LCD based on x and y coordinates
    void scroll(int _ix, int _iy);

    /// write a new line to LCD and scrolls previous line up
    void writeLine(const char *_pszFmt, ...);

    // indicate activity on LCD
    void blink();

    unsigned int width() const {return m_uBufWidth;}
    unsigned int height() const {return m_uBufHeightMask+1;}
    unsigned int x() const {return m_iX;}
    unsigned int y() const {return m_iY;}
    unsigned int lineCount() const {return m_uLineCount;}

  private:
    void setup();

  private:
    Serial             *m_pSerial;
    unsigned int       m_uBufWidth;
    unsigned int       m_uBufHeightMask;
    char               *m_pBuffer;
    unsigned long      m_uBufferSize;
    unsigned int       m_uLineCount;
    unsigned int       m_iX;
    unsigned int       m_iY;
    bool               m_bBlink;
    unsigned long      m_uBlinkMillis;
};



#endif  // #ifndef LCD_H

